import axios from '../../WuJiUtils/http'

// 渲染管理员
let noticeTest = async (_data: {
    limit: number,
    page: number
}) => {
    let data = await axios({
        url: '/userAdmin/list',
        method: 'post',
        params: _data
    })
    return data
}

// 渲染角色接口
let role = async () => {
    let data = await axios({
        url: '/userRole/findAll',
        method: 'get'
    })
    return data
}

// 添加管理员
let addAdmin = async (_data: {
    account: string,
    name: string,
    password: string,
    password2: string,
    remarks: string,
    role: string
}) => {
    let data = await axios({
        url: '/userAdmin/add',
        method: 'post',
        data: _data
    })
    return data
}

// 修改管理员
let editAdmin = async (_data: {
    account: string,
    remarks: string,
    password: string,
    name: string,
    role: string,
    id: number
}) => {
    let data = await axios({
        url: '/userAdmin/update',
        method: 'post',
        data: _data
    })
    return data
}

//删除管理员
let delAdmin = async (_data: {
    id: number
}) => {
    let data = await axios({
        url: '/userAdmin/delete',
        method: 'get',
        params: _data
    })
    return data
}

// 删除角色
let delRole = async (_data: {
    id: number
}) => {
    let data = await axios({
        url: '/userRole/deleteById',
        method: 'get',
        params: _data
    })
    return data
}

//添加角色
let addRoleName = async (_data: {
    name: string
}) => {
    let data = await axios({
        url: '/userRole/add',
        method: 'post',
        data: _data
    })
    return data
}
// 角色添加权限id
let roleToken = async (_data: {
    id: any,
    permissionIds: any
}) => {
    let data = await axios({
        url: '/userRole/updateRoleMenu',
        method: 'post',
        data: _data
    })
    return data
}

// 大文件上传接口
let bigFilePush = async (_data: {
    index: any,
    chunkTotal: any,
    fileSize: any,
    fileName: any,
    chunkSize: any,
    md5: any
}, formData1: any) => {
    let data = await axios({
        url: '/upload/chunk',
        method: 'post',
        params: _data,
        data: formData1
    })
    return data
}

// 断点续传
let com = async (_data: {
    md5: any
}) => {
    let data = await axios({
        url: '/check',
        method: 'get',
        params: _data
    })
    return data
}

export { noticeTest, addAdmin, editAdmin, delAdmin, role, delRole, addRoleName, roleToken, bigFilePush, com }